var t = getApp();

Page({
    data: {
        activeRule: null,
        info: {},
        rule: [],
        showCservice: !1,
        cserviceData: {}
    },
    onLoad: function(t) {
        this.getGood();
    },
    getGood: function() {
        var o = this, e = t.getNetAddresss("plugin.warehouse.frontend.controllers.purchasing.detail.index");
        t._postNetWork({
            url: e,
            data: {
                id: this.options.id
            },
            success: function(t) {
                var e = t.data;
                1 == e.result ? o.setData({
                    goodsInfo: e.data.get_goods,
                    rule: e.data.plugin_rules,
                    cserviceData: e.data.customer_service
                }) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    clickRule: function(t) {
        var o = t.currentTarget.dataset;
        this.setData({
            activeRule: o.num
        });
    },
    toOrder: function() {
        if (this.data.activeRule) {
            var o = t.getNetAddresss("plugin.warehouse.frontend.controllers.purchasing.order-create");
            t._postNetWork({
                url: o,
                data: {
                    goods_id: this.options.id,
                    goods_nums: this.data.activeRule
                },
                success: function(t) {
                    var o = t.data;
                    1 == o.result ? wx.navigateTo({
                        url: "/packageD/buy/orderPay/orderPay?status=1&order_id=" + o.data.order_ids
                    }) : wx.showToast({
                        icon: "none",
                        title: o.msg,
                        duration: 1e3
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        } else wx.showToast({
            icon: "none",
            title: "请选择规格！",
            duration: 1200
        });
    },
    showCserviceFun: function() {
        this.setData({
            showCservice: !0
        });
    },
    closePop: function() {
        this.setData({
            showCservice: !1
        });
    },
    gotoChat: function(o) {
        var e = o.currentTarget.dataset.cservice + "&goods_id=" + this.options.id;
        wx.navigateTo({
            url: e,
            fail: function(o) {
                t.tips("客服路由出错");
            }
        });
    },
    callPhone: function() {
        wx.makePhoneCall({
            phoneNumber: this.data.cserviceData.service_mobile
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});